'Copyright (c) Microsoft Corporation.  All rights reserved.

Imports Microsoft.VisualBasic
Imports System
Imports System.Collections.Generic
Imports System.ComponentModel
Imports System.Data
Imports System.Drawing
Imports System.Linq
Imports System.Text
Imports System.Windows.Forms
Imports Microsoft.WindowsAPICodePack.Shell
Imports Microsoft.WindowsAPICodePack.Shell.Taskbar
Imports System.IO

Namespace Microsoft.WindowsAPICodePack.Samples.TabbedThumbnailDemo
	Partial Public Class FavoritesWindow
		Inherits Form
        Private mainWindow As Form1 = Nothing

        Public Sub New(ByVal parent As Form1)
            mainWindow = parent

            InitializeComponent()

            explorerBrowser1.NavigationOptions.PaneVisibility.AdvancedQuery = Microsoft.WindowsAPICodePack.Shell.PaneVisibilityState.Hide
            explorerBrowser1.NavigationOptions.PaneVisibility.Commands = Microsoft.WindowsAPICodePack.Shell.PaneVisibilityState.Hide
            explorerBrowser1.NavigationOptions.PaneVisibility.CommandsOrganize = Microsoft.WindowsAPICodePack.Shell.PaneVisibilityState.Hide
            explorerBrowser1.NavigationOptions.PaneVisibility.CommandsView = Microsoft.WindowsAPICodePack.Shell.PaneVisibilityState.Hide
            explorerBrowser1.NavigationOptions.PaneVisibility.Details = Microsoft.WindowsAPICodePack.Shell.PaneVisibilityState.Hide
            explorerBrowser1.NavigationOptions.PaneVisibility.Navigation = Microsoft.WindowsAPICodePack.Shell.PaneVisibilityState.Hide
            explorerBrowser1.NavigationOptions.PaneVisibility.Preview = Microsoft.WindowsAPICodePack.Shell.PaneVisibilityState.Hide
            explorerBrowser1.NavigationOptions.PaneVisibility.Query = Microsoft.WindowsAPICodePack.Shell.PaneVisibilityState.Hide

            explorerBrowser1.ContentOptions.NoSubfolders = True
            explorerBrowser1.ContentOptions.NoColumnHeader = True
            explorerBrowser1.ContentOptions.NoHeaderInAllViews = True

            AddHandler explorerBrowser1.SelectionChanged, AddressOf explorerBrowser1_SelectionChanged
            AddHandler Load, AddressOf FavoritesWindow_Load
        End Sub

        Private Sub explorerBrowser1_SelectionChanged(ByVal sender As Object, ByVal e As EventArgs)
            If explorerBrowser1.SelectedItems.Count > 0 AndAlso TypeOf explorerBrowser1.SelectedItems(0) Is ShellFile Then
                Dim path As String = (CType(explorerBrowser1.SelectedItems(0), ShellFile)).Path

                If System.IO.Path.GetExtension(path).ToLower() = ".url" Then
                    If mainWindow IsNot Nothing Then
                        mainWindow.Navigate(path)
                    End If
                End If
            End If
        End Sub

		Private Sub FavoritesWindow_Load(ByVal sender As Object, ByVal e As EventArgs)
			explorerBrowser1.ContentOptions.ViewMode = ExplorerBrowserViewMode.List

			explorerBrowser1.Navigate(CType(KnownFolders.Favorites, ShellObject))
		End Sub
	End Class
End Namespace
